{extend name="index/index" /}
{block name="main"}
{js href="/static/index/js/jquery.min.js"}
<!-- Start right content -->

<!---->
<div class="content-page">

    <div class="content">

        <div class="page-heading">
            <h1><i class='fa fa-table'></i>评论管理</h1>
            <h3>帖子评论详情</h3></div>

        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>Sortable</strong> Table</h2>

                    </div>
                    {if ($list == null)}
                    <h1 style="color:darkred;text-align: center; height: 300px;line-height: 300px;">还没有评论呢</h1>
                    {else /}
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th class="col-md-1">评论名</th>
                                    <th class="col-md-1">评论用户</th>
                                    <th>评论内容</th>
                                    <th class="col-md-1">评论时间</th>
                                    <th class="col-md-1">评论喜欢</th>
                                    <th class="col-md-1">评论讨厌</th>
                                    <th class="col-md-3">操作</th>

                                    {volist name='list' id='val' }
                                <tr>
                                    <td>{$val.postcom_id}</td>
                                    <td>{$val.username}</td>
                                    <td>{$val.comcontent}</td>
                                    <td>{$val.commenttime}</td>
                                    <td>{$val.comlove}</td>
                                    <td>{$val.comhit}</td>
                                    <td>
                                        <a href="{:url('admin/comment/postruncom',['id' => $val.postcom_id])}" class="btn btn-info">查看追评</a>
                                        <a class="btn btn-danger delpc" data-id="{$val.postcom_id}">删除</a>
                                    </td>
                                </tr>
                                {/volist}

                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                    {/if}

                </div>
            </div>
        </div>




        <!-- Footer Start -->
        <footer>
            Huban Creative &copy; 2014
            <div class="footer-links pull-right">
                <a href="#">About</a><a href="#">Support</a><a href="#">Terms of Service</a><a href="#">Legal</a><a
                    href="#">Help</a><a href="#">Contact Us</a>
            </div>
        </footer>
        
    </div>
    

</div>
<!-- End right content -->

<script type="text/javascript">


    $(function () {
        // 触发删除用户
        $('.delpc').click(function () {
            var dataid = $(this).attr('data-id');
//            alert(dataid);

            if (confirm('您确定要 [ 删 除 ] 该评论吗?')) {
                var obj = $(this).parents('tr');

//                 console.log(obj);
                delAjax(dataid, obj); // 执行AJAX删除

            }
        });
    })





    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: true,// 实现显示计时条
        timeOut: "1000",// 自动关闭时间
        positionClass: "toast-bottom-left"// 提示位置
        // positionClass: "toast-top-full-width"// 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };

    function delAjax(id,obj) {



        var info = 'pcid'+'='+id;
        // alert(info);

        $.ajax({
            type: 'post',
            url: '/admin/comment/delpc',
            data: info,
            dataType : 'json',
            success : function (data){

                if (data.status) {
                    toastr.success('删除评论成功');
                    obj.remove();
                } else {
                    toastr.error('删除评论失败');
                }
                // alert(data.pcid);


            },
            error : function () {
                alert('执行失败');

            }
        });
    }

</script>


{/block}